Programming Questions for Practice
Find the minimum element in a sorted and rotated array.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int size;
printf("\nEnter the size of the array: ");
scanf("%d", &size);
int array[size];
printf("\nEnter any %d numbers: ", size);
for(int i = 0; i < size; i++)
scanf("%d", &array[i]);
for(int i = 0; i < size; i++) {
if(array[i] >= array[i+1]) {
printf("\nMinimum element is %d\n", array[i+1]);
return;
}
}
return 0;
}